package com.approval.approvalapp.index.cygn.hys;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.HysListBean;
import com.approval.approvalapp.index.cygn.HysSyjlListActivity;
import com.approval.approvalapp.util.ErrorBeanUtil;
import com.approval.approvalapp.util.SpUtil;
import com.approval.approvalapp.util.base.BaseActivity;
import com.approval.approvalapp.util.net.NetRequsetUtil;
import com.approval.approvalapp.util.net.interfacepac.NetDownResponse;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class HysListActivity extends BaseActivity {


    @Bind(R.id.back_iv)
    ImageView backIv;
    @Bind(R.id.titleTv1)
    TextView titleTv1;
    @Bind(R.id.rv)
    RecyclerView rv;
    @Bind(R.id.syjl_ll)
    LinearLayout syjl_ll;
    private HysListAdapter hysListAdapter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_hys_list;
    }

    @Override
    public void initView() {

        rv.setLayoutManager(new LinearLayoutManager(this));
        hysListAdapter = new HysListAdapter();
        rv.setAdapter(hysListAdapter);
    }

    @Override
    public void initData() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("region_code",
                SpUtil.getString(this,SpUtil.REGION_CODE,""));
        NetRequsetUtil.getInstance().netRequestPostJson("v1/center/meeting_all_index",
                jsonObject.toString()
                , new NetDownResponse() {
                    @Override
                    public void success(String str) {
                        List<HysListBean> hysListBeanList = JSON.parseArray(str,HysListBean.class);
                        hysListAdapter.setHysListBeanList(hysListBeanList);

                    }

                    @Override
                    public void errowithresponse(String str) {
                        ErrorBeanUtil.getErrorMessage(str);
                    }

                    @Override
                    public void erro() {

                    }

                    @Override
                    public void finish() {

                    }
                });

        syjl_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(HysListActivity.this, HysSyjlListActivity.class);
                startActivity(intent);
            }
        });
    }


    @OnClick(R.id.back_iv)
    public void onViewClicked() {
        finish();
    }
}
